//
//  HZHomeModel.m
//  微博 OC
//
//  Created by 黑眼圈 on 16/4/21.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZHomeModel.h"

@implementation HZHomeModel


//KVC
+(instancetype)homeWithDict:(NSDictionary*)dict{
    
    HZHomeModel* homeModel = [[HZHomeModel alloc]init];
    
    [homeModel setValuesForKeysWithDictionary:dict];
    
    return homeModel;
}





//防止 kvc 报错
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
//    [super setValue:value forUndefinedKey:key];
}




-(void)setValue:(id)value forKey:(NSString *)key{
    
  
    
    //如果是个人信息,需要再转换一层字典
    if ([key isEqualToString:@"user"]) {
        
        //把数据装换成字典类型
        NSDictionary* dict = (NSDictionary*)value;
        
        self.user = [HZHomeUserModel userWithDict:dict];
    }else{
        
        [super setValue:value forKey:key];
    }
    
}




@end
